<?php

require_once dirname(__FILE__) . '/../../Extension/Params.php';
require_once dirname(__FILE__) . '/TextValues.php';

class Rams_Extension_PayedParams extends Raws_Extension_Params
{
  
  // protected $_rootNamespace = 'raws';
  // protected $_rootElement = 'params';

    # child elements of the params element
    protected $_year = null;
    protected $_month = null;
    protected $_credits = null;
    protected $_formula = null;

    public function __construct() 
    {
        parent::__construct();
    }
    
    /**
     * Retrieves a DOMElement which corresponds to this element and all
     * child properties.  This is used to build an entry back into a DOM
     * and eventually XML text for application storage/persistence.
     *
     * @param DOMDocument $doc The DOMDocument used to construct DOMElements
     * @return DOMElement The DOMElement representing this element and all
     *          child properties.
     */
    public function getDOM($doc = NULL, $majorVersion = 1, $minorVersion = NULL)
    {
        $element = parent::getDOM($doc);
        if ($this->_year !== null) {
            $element->appendChild($this->_year->getDOM($element->ownerDocument));
        }
        if ($this->_month !== null) {
            $element->appendChild($this->_month->getDOM($element->ownerDocument));
        }
        if ($this->_credits != null) {
          $element->appendChild($this->_credits->getDOM($element->ownerDocument));
        }
        if ($this->_formula != null) {
          $element->appendChild($this->_formula->getDOM($element->ownerDocument));
        }
        
        return $element;
    }

    /**
     * Creates individual Entry objects of the appropriate type and
     * stores them as members of this entry based upon DOM data.
     *
     * @param DOMNode $child The DOMNode to process
     */
    protected function takeChildFromDOM($child)
    {
        $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
        
        switch ($absoluteNodeName) {
            case $this->lookupNamespace('raws') . ':' . 'year'; 
                $year = new Rams_Extension_Year();
                $year->transferFromDOM($child);
                $this->_year = $year;
                break;
            case $this->lookupNamespace('raws') . ':' . 'month'; 
                $month = new Rams_Extension_Month();
                $month->transferFromDOM($child);
                $this->_month = $month;
                break;
            case $this->lookupNamespace('raws') . ':' . 'credits'; 
                $credits = new Rams_Extension_Credits();
                $credits->transferFromDOM($child);
                $this->_credits = $credits;
                break;
            case $this->lookupNamespace('raws') . ':' . 'formula'; 
                $formula = new Rams_Extension_Formula();
                $formula->transferFromDOM($child);
                $this->_formula = $formula;
                break;
              
            default:
                parent::takeChildFromDOM($child);
                break;
        }
    }
    
    public function getYear()
    {
        return $this->_year;
    }

    public function setYear($value)
    {
        $this->_year = $value;
        return $this;
    }

    public function getMonth()
    {
        return $this->_month;
    }

    public function setMonth($value)
    {
        $this->_month = $value;
        return $this;
    }

    public function getCredits()
    {
        return $this->_credits;
    }

    public function setCredits($value)
    {
        $this->_credits = $value;
        return $this;
    }

    public function getFormula()
    {
        return $this->_formula;
    }

    public function setFormula($value)
    {
        $this->_formula = $value;
        return $this;
    }

}
